<%
# Copyright (C) 2015 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<p><%= mt(<<-TEXT, metadata_url: link_to(aac.entity_id, aac.entity_id))
The Canvas SAML Entity ID is %{metadata_url}, and the Service Provider metadata
is available at that URL.
TEXT
%></p>
<% css_bundle :saml_fields %>
<p><%= t(<<-TEXT)
Provide a URI to your IdP's metadata to automatically populate the other
fields. If your school is part of InCommon or the UK Access Management
Federation, specify urn:mace:incommon or http://ukfederation.org.uk,
respectively, for the metadata URI, and also provide your school's entity ID.
TEXT
%></p>
<div class="ic-Form-control">
  <%= f.label :metadata_uri, t('IdP Metadata URI'), class: 'ic-Label', for: "metadata_uri_#{presenter.id_suffix(aac)}" %>
  <%= f.text_field :metadata_uri, class: 'ic-Input', id: "metadata_uri_#{presenter.id_suffix(aac)}" %>
</div>
<div class="ic-Form-control">
  <%= f.label :idp_entity_id, t('IdP Entity ID'), class: 'ic-Label', for: "idp_entity_id_#{presenter.id_suffix(aac)}" %>
  <%= f.text_field :idp_entity_id, class: 'ic-Input', id: "idp_entity_id_#{presenter.id_suffix(aac)}" %>
</div>
<div class="ic-Form-control">
  <%= f.label :log_in_url, t('Log On URL'), class: 'ic-Label', for: "log_in_url_#{presenter.id_suffix(aac)}" %>
  <%= f.text_field :log_in_url, class: 'ic-Input', id: "log_in_url_#{presenter.id_suffix(aac)}" %>
</div>
<div class="ic-Form-control">
  <%= f.label :log_out_url, t('Log Out URL'), class: 'ic-Label', for: "log_out_url_#{presenter.id_suffix(aac)}" %>
  <%= f.text_field :log_out_url, class: 'ic-Input', id: "log_out_url_#{presenter.id_suffix(aac)}" %>
</div>
<div class="ic-Form-control">
  <%= f.label :certificate_fingerprint, t('Certificate Fingerprint'), class: 'ic-Label', for: "certificate_fingerprint_#{presenter.id_suffix(aac)}" %>
  <%= f.text_field :certificate_fingerprint, class: 'ic-Input', id: "certificate_fingerprint_#{presenter.id_suffix(aac)}" %>
</div>
<%= render partial: 'login_attribute_dropdown', locals: { aac: aac, presenter: presenter, f: f } %>
<div class="ic-Form-control">
  <%= f.label :identifier_format, 'Identifier Format', class: 'ic-Label', for: "identifier_format_#{presenter.id_suffix(aac)}" %>
  <%= f.select(:identifier_format,
               presenter.saml_identifiers,
               {},
               class: 'ic-Input', id: "identifier_format_#{presenter.id_suffix(aac)}") %>
</div>
<div class="ic-Form-control">
  <%= f.label :requested_authn_context, 'Authentication Context', class: 'ic-Label', for: "requested_authn_context_#{presenter.id_suffix(aac)}" %>
  <%= f.select(:requested_authn_context,
               presenter.saml_authn_contexts,
               {},
               class: 'ic-Input', id: "requested_authn_context_#{presenter.id_suffix(aac)}") %>
</div>
<% if @account.self_registration? %>
    <div id="parent_reg_selected" data-parent-reg-selected="<%= presenter.parent_reg_selected %>"></div>
    <div class="ic-Form-control">
      <%= f.label :parent_registration, "Parent Registration", class: 'ic-Label', for: "parent_registration_#{presenter.id_suffix(aac)}" %>
      <%= f.check_box :parent_registration, class: "parent_reg_warning", id: "parent_registration_#{presenter.id_suffix(aac)}" %>
      <span class="SAML_parent_default" ><%= t "Use this configuration for parent/observer registration" %></span>
      <div class="parent_form_message">
        <div class="parent_form_message_layout">
          <i class="parent_icon_warning"></i>
          <span class="parent_warning_message"></span>
        </div>
      </div>
    </div>
<% end %>
<%= render partial: 'jit_provisioning_field', locals: { aac: aac, presenter: presenter, f: f } %>
